package com.flats.service.transactional;

import com.flats.model.dao.Dao;
import com.flats.model.entity.Owner;
import com.flats.service.OwnerService;
import org.springframework.transaction.annotation.Transactional;

import java.io.Serializable;
import java.util.List;

@Transactional
public class TransactionalOwnerService implements OwnerService {

    private Dao<Owner> ownerDao;

    public void setOwnerDao(Dao<Owner> ownerDao) {
        this.ownerDao = ownerDao;
    }

    @Override
    @Transactional
    public Serializable saveOrUpdate(Owner persistent) {
        return ownerDao.saveOrUpdate(persistent);
    }

    @Override
    @Transactional
    public void delete(Long id) {
        ownerDao.delete(id);
    }

    @Override
    @Transactional
    public void delete(Owner persistent) {
        ownerDao.delete(persistent);
    }

    @Override
    @Transactional
    public Owner get(Long id) {
        return ownerDao.get(id);
    }

    @Override
    @Transactional
    public List<Owner> getAll() {
        return ownerDao.getAll();
    }
}
